package cn.myjerry.others.guava;

import java.util.Set;

import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;

/**
 * 统计单词的出现次数
 * 1、hashMap 分拣存储+面向对象思维 --> 判断
 * 2、Multiset 无序+可重复		.count() 增强了可读性+操作简单
 * @author Jerry
 *
 */
public class Demo05 {
	public static void main(String[] args) {
		String str = "this is a cat and that is a mice where is the food";
		String[] strArr = str.split(" ");
		Multiset<String> set = HashMultiset.create();
		for(String temp:strArr) {
			set.add(temp);
		}
		Set<String> letters = set.elementSet();
		for(String temp:letters) {
			System.out.println(temp + "==>" + set.count(temp));
		}		
	}
}
